package com.wen;

import com.wen.util.ScanObject;
import com.wen.util.Scanner;
import com.wen.util.TasklistUtil;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description:
 * @Author: wenxin
 * @Date: 2022/6/23 13:55
 * @Version: 1.0
 */
public class main {
    public static void main(String[] args) throws IOException {


        LocalDate localDate = YearMonth.parse("2022-06", DateTimeFormatter.ofPattern("yyyy-MM")).atDay(1);
        LocalDate firstDay = localDate.with(TemporalAdjusters.firstDayOfMonth());
        LocalDate lastDay = localDate.with(TemporalAdjusters.lastDayOfMonth());
        System.out.println(firstDay);
        System.out.println(lastDay);

        Scanner scanner = new Scanner("127.0.0.1","80-80");
        scanner.start();

        //任务列表
        List<ScanObject> scanObjects = scanner.getScanObjectList();
        //有未执行和执行中的数据
        Long activityNum=0L;
        do {
            activityNum=scanObjects.stream().filter(x->{
                return x.getState()==0||x.getState()==1;
            }).count();
            List<ScanObject> s=scanObjects.stream().filter(x->{
                return x.getState()==0||x.getState()==1;
            }).collect(Collectors.toList());
            System.out.println(activityNum+"/"+scanObjects.size());
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
        }while (activityNum>0||scanner.getRun());
    }
}
